<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib tagdir="/WEB-INF/tags/busterminal/" prefix="bt"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Bus Terminal</title>
        <bt:IncludedFiles />
        <%
            String path = getServletContext().getContextPath().replaceAll("^\\/|\\/$", "");
            StringBuilder sb = new StringBuilder();
            sb.append("<script type=\"text/javascript\">").append("\n");
            sb.append("\t").append("$(document).ready(function() {").append("\n");
            if (request.getSession().getAttribute("showPage") != null) {
                sb.append("\t").append("loadPage(\"").append((String) session.getAttribute("showPage")).append("\");").append("\n");
                request.getSession().removeAttribute("showPage");
            } else if (request.getSession().getAttribute("defaultPage") != null) {
                sb.append("\t").append("loadPage(\"").append((String) session.getAttribute("defaultPage")).append("\");").append("\n");
            } else if (request.getSession().getAttribute("user") == null) {
                sb.append("\t").append("loadPage(\"").append("scheduled-item-list").append("\");").append("\n");
            } else {
                sb.append("\t").append("var curPath = location.pathname.replace(/^\\/|\\/$/g, '');").append("\n");
                sb.append("\t").append("if (!(curPath == \"").append(path).append("\" || curPath == \"").append(path).append("/MainServlet\" || curPath == \"").append(path).append("/mainpage\")) {").append("\n");
                sb.append("\t\t").append("loadPage(\"").append(getServletContext().getContextPath()).append("\");").append("\n");
                sb.append("\t").append("}").append("\n");
            }
            sb.append("\t").append("});").append("\n");
            sb.append("</script>").append("\n");
            out.write(sb.toString());
        %>
    </head>
    <body>
        <bt:NavigationBar />
        <div class="container-fluid offsetted">
            <div id="results"></div>
            <div class="waitpage">
                <div class="progress progress-striped active" style="margin-top: 25%;">
                    <div class="bar" style="width: 100%;"></div>
                </div>
            </div>
        </div>
    </body>
</html>
